Completed
Push — master ( f15d30...b9cea7 )
by Simon
28s
created

test.js ➔ ???   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
const fisherMan = require('../')
2
const Test = require('./middlewareTest')
3
const {token} = require('./auth.json')
4
var middleware = new Test()
5
var bot = new fisherMan.Fisherman({ prefixes: ['fish!'] })
6
bot.use(middleware)
7
var register = bot.createRegister('test', 'test')
8
console.log('registerCreated')
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
9
register.textCommand('test', null, function (req, res) {
10
  res.send(`Command infos:\nName: ${req.command.name}\nRegister name: \`${req.command.register.name}\`\nTotal command count in the fisherman client: ${req.client.commands.size}\nPassed through the middleware proof: ${req.test}`, { embed: { description: 'This request was made through the fishman project' } })
11
})
12
register.textCommand('ping', null, function (req, res) {
13
  var current = Date.now()
14
  res.send('Pinging......').then((message) => {
15
    message.edit((Date.now() - current) + 'ms')
16
  })
17
})
18
register.promiseCommand(['text'], 'promise', null, function (req, res, resolve, reject) {
0 ignored issues
show
Unused Code introduced by
The parameter reject is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
19
  res.send('Resolving the promise command')
20
  resolve({message: "I'm resolved yeeeeeeeeeeeeeee"})
21
})
22
register.promiseCommand(['text'], 'promisereject', null, function (req, res, resolve, reject) {
23
  res.send('Rejecting the promise command')
24
  reject(new Error("I'm rejected"))
25
})
26
bot.init(token)
27
bot.on('fisherCode', function (router, code, err) {
28
  router.response.send('fisherCode ' + code + '\nError message: ' + err.message)
29
})
30
const Command = fisherMan.Command
31
class SimpleCommand extends Command {
32
  constructor () {
33
    super('SimpleCommand', register)
34
    this.aliases = ['catting']
35
  }
36
  execute (req, res) {
37
    res.send('Yeeeeeeeeeeeeeeeeeeeeeeeeeeeee')
38
  }
39
}
40
register.addCommand(new SimpleCommand())
41
register.textCommand('match', {regPattern: new RegExp('(<@[0-9]+>|<@![0-9]+>)')}, function (req, res) {
42
  res.send('command trigerred: ' + this.regPattern.exec(this.suffixe)[0])
43
})
44
console.log(register.size)
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
45